#include<bits/stdc++.h>

using namespace std;

/**
 * 大整数加法c=a+b 多项式加法
 * @param a
 * @param b
 * @param c
 */
void add(vector<int> a, vector<int> b, vector<int> &c) {
    if (a.size() < b.size())swap(a, b);
    b.resize(a.size());
    c.resize(a.size());
    int cs = 0;
    for (int i = 0; i < a.size(); i++) {
        int temp = a[i] + b[i] + cs;
        c[i] = temp % 10;
        cs = temp / 10;

    }
    if (cs > 0) {
        c.push_back(cs);
    }
}

int main() {
    vector<int> a = {1, 2, 3, 9}; //9321
    vector<int> b = {9, 8, 7}; //0789
    vector<int> c;
    add(a, b, c);
    copy(c.rbegin(), c.rend(), ostream_iterator<int>(cout, ""));

    return 0;
}
